package com.yyyit.bg2.controller;

import java.util.concurrent.TimeUnit;

import org.apache.logging.log4j.message.Message;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.Select;

import com.yyyit.bg2.tools.tools;

public class Goods {

	public static String addGood(WebDriver driver, String baseUrl) {
		try {

			driver.get(baseUrl + "marketbg/#/marketbg/goods");
			driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
			driver.findElement(By.linkText("新增")).click();
			driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
			driver.findElement(By.xpath("//input[@placeholder='请输入货品标题']"))
					.sendKeys("test" + tools.time8());
			driver.findElement(By.xpath("//input[@placeholder='请输入货品摘要']"))
					.sendKeys("test" + tools.time8());
			Select s = new Select(driver.findElement(By
					.xpath("//select[@ng-model='entity.providerId']")));
			s.selectByVisibleText("自动化");
			
			
			
			driver.findElement(By.name("mobile")).sendKeys("15001300532");
			driver.findElement(By.xpath("//button[@ng-click='confirm()']"))
					.click();
			return "添加商品成功";
		} catch (Exception e) {
			// TODO: handle exception
		} finally {

		}
		return "添加商品失败";

		// return "555 人家还没有准备好呢。";
	}

}
